<?php
namespace app\plugin\controller\shop;

use app\BaseController;
use app\plugin\model\shop\Column as ColumnModel;
use think\Exception;

class Column extends BaseController
{
    public function index()
    {
        return view();
    }

    public function list()
    {
        try {
            $column  = new ColumnModel();
            $limit = input('limit', 10);
            $columns = $column->paginate($limit);

            foreach ($columns as $column){
                $column->parent = '';
                if($column->pname){
                    $column->parent = $column->pname->name;
                }
            }

            return lay_data($columns);
        } catch (Exception $e) {
            return lay_data(false, $e->getMessage());
        }
    }
}